import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    TouchableHighlight
} from 'react-native';

export  default  class SecondPage extends  Component{
    constructor(props){
        super(props);
        this.state={
            id:null
        }
    }
   clickJump(){
        if(this.props.getUser){
            this.props.getUser("天空");
        }
       const {navigator}=this.props;
       if(navigator){
           navigator.pop();
       }
   }

    componentDidMount(){
        this.setState({
            title:this.props.title,
            id:this.props.id
        })
    }
    render(){
        return(
            <View style={styles.container}>
                <Text>第二个界面</Text>
                <TouchableHighlight
                    underlayColor="rgb(181,136,254)"
                    activeOpacity={0.5}
                    style={{ borderRadius: 8,padding: 8,marginTop:5,backgroundColor:"#0588fe"}}
                onPress={this.clickJump.bind(this)}>
                    <Text>点击进入第一个界面</Text>
                </TouchableHighlight>
                <Text>第一个界面返回title:{this.state.title}</Text>
                <Text>第一个界面返回id:{this.state.id}</Text>
            </View>
        )
    }
}

const  styles=StyleSheet.create({
    container:{
        flex: 1,
        backgroundColor:"#ffffff",
        justifyContent:"center",
        alignItems: 'center',
    }
})